package com.wicket.okrbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrbff.biz.service.TypeCodeService;
import com.wicket.okrbff.biz.service.dto.req.*;
import com.wicket.okrbff.biz.service.dto.res.*;
import com.wicket.okrbff.common.util.RedisUtil;
import com.wicket.okrframework.integration.FwBaseInductionRecordClient;
import com.wicket.okrframework.integration.FwBaseTypeCodeClient;
import com.wicket.okrframework.integration.dto.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;
import com.wicket.okrbff.common.exception.Assert;
import java.util.ArrayList;
import java.util.List;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class TypeCodeServiceImpl implements TypeCodeService {
    @Resource
    FwBaseTypeCodeClient typeCodeClient;
    @Resource
    FwBaseInductionRecordClient inductionRecordClient;
    @Resource
    FwBaseTypeCodeClient fwBaseTypeCodeClient;
    @Resource
    FwBaseInductionRecordClient fwBaseInductionRecordClient;
    @Resource
    private RedisUtil redisUtil;


    /**
   * B查询编码列表（公共）[644]
   * gen by moon at 9/27/2022, 9:36:46 AM
   */
    @Trace(operationName = "B查询编码列表（公共）")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryCodeListComRespDto queryCodeListCom(BffQueryCodeListComReqDto reqDto){
      
       
       QueryCodeListComRespDto queryCodeListComRespDto_1 =null;
//步骤0: D1-1查询编码列表(公共) - queryCodeListCom
     QueryCodeListComRespDto queryCodeListComRespDto = null;
    QueryCodeListComReqDto queryCodeListComReqDto=new QueryCodeListComReqDto();
  queryCodeListComReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:14561_1
if(reqDto!=null){
      queryCodeListComReqDto.setTypeCode(reqDto.getTypeCode());//sourceId:11019_1
    }
  
    /*D1-1查询编码列表(公共)[648]   */
    Assert.isNull(queryCodeListComReqDto.getTypeCode(),"B查询编码列表（公共）-D1-1查询编码列表(公共)-类型的编码不能为空",false);
Assert.isNull(queryCodeListComReqDto.getSubjectLifeCycle(),"B查询编码列表（公共）-D1-1查询编码列表(公共)-主体生命周期不能为空",false);
      queryCodeListComRespDto = fwBaseTypeCodeClient.queryCodeListCom(queryCodeListComReqDto).getData();
      Assert.isTrue(queryCodeListComRespDto== null||  queryCodeListComRespDto.getTypeEncodingList() ==null|| queryCodeListComRespDto.getTypeEncodingList().size()==0 ,"返回值不能为空",false);
      
      queryCodeListComRespDto_1 = queryCodeListComRespDto;
    
BffQueryCodeListComRespDto retData = new BffQueryCodeListComRespDto();
  if(queryCodeListComRespDto_1!=null){
      retData.setTypeEncodingList(queryCodeListComRespDto_1.getTypeEncodingList().stream().map(item -> BeanUtil.toBean(item, BffTypeEncodingDto.class)).collect(Collectors.toList()));//sourceId:11034_1
    }
  

  
  
return retData;
  }


    //
}
